package com.sh.suhe.utildemos.book.base;

import android.annotation.SuppressLint;
import android.app.Activity;
import android.content.Intent;
import android.os.Build;
import android.os.Build.VERSION;
import android.os.Bundle;
import android.view.Window;

import androidx.annotation.Nullable;

import butterknife.ButterKnife;
import com.liuguang.framework.base.BaseActivity;
import com.sh.suhe.utildemos.R;
import com.umeng.analytics.MobclickAgent;
import java.lang.reflect.Field;
import java.lang.reflect.Method;

public abstract class BaseMvpActivity<T extends BasePresenter> extends BaseActivity {
    private boolean mEnabled = false;
    public T presenter;

    public abstract int getLayoutId();

    public abstract void initData();

    public abstract void initListener();

    public abstract void initView();

    public abstract void loadData();

    public abstract T setPresenter();

    /* JADX WARNING: type inference failed for: r1v0, types: [com.xmread.cn.base.BaseMvpActivity, com.liuguang.framework.base.BaseActivity, android.app.Activity] */
    /* access modifiers changed from: protected */
    @SuppressLint("WrongConstant")
    public void onCreate(@Nullable Bundle bundle) {
        BaseMvpActivity.super.onCreate(bundle);
        setContentView(getLayoutId());
        setStatusBar(getResources().getColor(R.color.white));
        ButterKnife.bind(this);
        this.presenter = setPresenter();
        if (getResources().getConfiguration().orientation != 2 || this.mEnabled) {
            initData();
            initView();
            initListener();
            loadData();
            return;
        }
        setRequestedOrientation(1);
    }

    /* JADX WARNING: type inference failed for: r2v0, types: [com.xmread.cn.base.BaseMvpActivity, android.content.Context, com.liuguang.framework.base.BaseActivity] */
    /* access modifiers changed from: protected */
    public void onStart() {
        BaseMvpActivity.super.onStart();

    }

    public void onDestroy() {
        BaseMvpActivity.super.onDestroy();
        if (this.presenter != null) {
            this.presenter.onDestroy();
            this.presenter = null;
        }
    }

    public void setOrientationEnabled(boolean z) {
        this.mEnabled = z;
    }



    /* JADX WARNING: type inference failed for: r1v0, types: [com.xmread.cn.base.BaseMvpActivity, android.content.Context, com.liuguang.framework.base.BaseActivity] */
    /* access modifiers changed from: protected */
    public void onActivityResult(int i, int i2, Intent intent) {
        BaseMvpActivity.super.onActivityResult(i, i2, intent);
//        UMShareAPI.get(this).onActivityResult(i, i2, intent);
    }

    public void setStatusBar(int i) {
        if (VERSION.SDK_INT >= 23) {
            if (VERSION.SDK_INT >= 24) {
                try {
                    Field declaredField = Class.forName("com.android.internal.policy.DecorView").getDeclaredField("mSemiTransparentStatusBarColor");
                    declaredField.setAccessible(true);
                    declaredField.setInt(getWindow().getDecorView(), 0);
                } catch (Exception unused) {
                }
            }
            Window window = getWindow();
            window.addFlags(Integer.MIN_VALUE);
            window.clearFlags(67108864);
            window.setStatusBarColor(i);
            setStatusTextColor(true);
        }
    }

    /* JADX WARNING: type inference failed for: r1v0, types: [com.xmread.cn.base.BaseMvpActivity, android.app.Activity] */
    public void setStatusTextColor(boolean z) {
        if (z) {
            if (Build.MANUFACTURER.equalsIgnoreCase("xiaomi")) {
                setStatusBarDarkMode(true, this);
            }
            getWindow().getDecorView().setSystemUiVisibility(8192);
            return;
        }
        if (Build.MANUFACTURER.equalsIgnoreCase("xiaomi")) {
            setStatusBarDarkMode(false, this);
        }
        getWindow().getDecorView().setSystemUiVisibility(0);
    }

    public void setStatusBarDarkMode(boolean z, Activity activity) {
        Class cls = activity.getWindow().getClass();
        try {
            Class cls2 = Class.forName("android.view.MiuiWindowManager$LayoutParams");
            int i = cls2.getField("EXTRA_FLAG_STATUS_BAR_DARK_MODE").getInt(cls2);
            Method method = cls.getMethod("setExtraFlags", new Class[]{Integer.TYPE, Integer.TYPE});
            Window window = activity.getWindow();
            Object[] objArr = new Object[2];
            objArr[0] = Integer.valueOf(z ? i : 0);
            objArr[1] = Integer.valueOf(i);
            method.invoke(window, objArr);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    /* JADX WARNING: type inference failed for: r1v0, types: [com.xmread.cn.base.BaseMvpActivity, android.content.Context, com.liuguang.framework.base.BaseActivity, java.lang.Object] */
    public void onResume() {
        BaseMvpActivity.super.onResume();
        MobclickAgent.onResume(this);
//        if (!(this instanceof MainActivity)) {
//            MobclickAgent.onPageStart(getClass().getName());
//        }
    }

    /* JADX WARNING: type inference failed for: r1v0, types: [com.xmread.cn.base.BaseMvpActivity, android.content.Context, com.liuguang.framework.base.BaseActivity, java.lang.Object] */
    public void onPause() {
        BaseMvpActivity.super.onPause();
        MobclickAgent.onPause(this);
//        if (!(this instanceof MainActivity)) {
//            MobclickAgent.onPageEnd(getClass().getName());
//        }
    }
}
